<?php

/**
 *      [品牌空间] (C)2001-2010 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: ads.inc.php 4379 2010-09-09 03:00:50Z fanshengshuai $
 */

if(!defined('IN_ADMIN')) {
	exit('Acess Denied');
}

require_once B_ROOT . "source/class/adv/adv_core.php";

class adv_couplebanner extends Adv {

	var $version = '1.0';
	var $name = 'couplebanner_name';
	var $description = 'couplebanner_desc';

	function getSettings() {
		global $_G;
		$settings = array(
			'position' => array(
				'title' => 'couplebanner_position',
				'type' => 'mradio',
				'value' => array(
					array(1, 'couplebanner_position_left'),
					array(2, 'couplebanner_position_right'),
				),
				'default' => 1,
			),
			'coupleadid' => array(
				'title' => 'couplebanner_coupleadid',
				'type' => 'select',
				'value' => array(),
			),
		);

		$query = DB::query('SELECT * FROM '.DB::table('advertisement')." WHERE type='couplebanner'");
		while($couple = DB::fetch($query)) {
			$settings['coupleadid']['value'][] = array($couple['advid'], $couple['title']);
		}

		return $settings;
	}

	function setSettings(&$advnew, &$parameters) {
		global $_G, $checkresults, $lang;
		parent::setSettings($advnew, $parameters);

		$cache_file = B_ROOT."data/system/ad_couplebanner.cache.php";
		@include_once($cache_file);
		if (($parameters[extra][position] == $_G['cache']['ad']['couplebanner'][$parameters['extra']['coupleadid']]['parameters']['extra']['position']) && $_G['gp_advid'] != $parameters['extra']['coupleadid']) {
			$checkresults[] = array('parameters[extra][coupleadid]'=>$lang['adv_couplebanner_coupleadid_error']);
		}
	}
}

?>